package cn.tedu.seckill.config

import org.springframework.amqp.core.Binding
import org.springframework.amqp.core.BindingBuilder
import org.springframework.amqp.core.DirectExchange
import org.springframework.amqp.core.Queue
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import cn.tedu.staticResources.ComRe

@Configuration
class RabbitmqConfig {

  //声明内存对象,在连接rabbitmq后,
  //使用时调用对象数据

  //声明队列对象 路由模式解决秒杀
  @Bean
  def queue01 = new Queue(ComRe.seckillQ01,false, false, false, null)

  //声明交换机 路由模式
  @Bean
  def ex01 = new DirectExchange(ComRe.seckillEX)

  //队列与交换机的绑定关系
  @Bean
  def bind01 = BindingBuilder.bind(queue01).to(ex01).`with`(ComRe.seckill)

}